# -*-  coding:utf-8 -*- 
# Author : lihongliang
def print_log(msg,log_type="info"):
    if log_type == "info":
        print(msg)
    elif  log_type == "error":
        print("\033[31;1m \s \033[0n")


def syntax_where(where_clause):
    """
    解析where条件
    :param clause: 
    :return: 
    """
    operators = {
        '>':op_dayu,
    }
    for op_key ,op_func in operators.items():
        if op_key in where_clause:
            #print("clause:",clause)
            column,condtion = where_clause.split(op_key)
            # print(column)
            # print(condtion)
            matched_data =  op_func(column.strip(),condtion.strip())
            print_log(matched_data)
            break
    else: #只有在for执行完成，且中间没有被break情况下执行
        print_log("语法错误： where 条件只能支持[>,<,=,like ]",'error')


def syntax_parser(cmd):
    """
    :param cmd: 
    :return: 
    """
    # find name,age from staff_table where age > 22
    if  cmd.split()[0] in ('find','add','del','update'):
        query_clause ,where_clause = cmd.split("where")
        # print(query_clause,where_clause)
        syntax_where(where_clause)
    else:
        print_log("语法错误：\n[find\\add\\del\\update][column,...]from [staff_table][where][column][>...][condition] \n ",'error' )


def main():
    while True:
        cmd = input("请输入要查询的数据：").strip()
        if not cmd:continue
        syntax_parser(cmd)

main()